package com.hbyj.struts.action;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.poi.hssf.record.formula.functions.Db;
import org.apache.struts2.ServletActionContext;

import com.hbyj.db.function.DbTools;
import com.hbyj.util.Constants;
import com.hbyj.util.PageClass;
import com.opensymphony.xwork2.ActionSupport;

public class FxbbAction extends ActionSupport{
	private String jsonResult;
	private int total;
	private List rows = new ArrayList();
	
	public String getJsonResult() {
		return jsonResult;
	}

	public void setJsonResult(String jsonResult) {
		this.jsonResult = jsonResult;
	}

	public int getTotal() {
		return total;
	}

	public void setTotal(int total) {
		this.total = total;
	}

	public List getRows() {
		return rows;
	}

	public void setRows(List rows) {
		this.rows = rows;
	}
	
	public String queryFxbb(){
		HttpServletRequest request = ServletActionContext.getRequest();
		String pageNo = request.getParameter("page");
		int pageSize = Constants.PAGE_KEY;
		String startTime = request.getParameter("startTime");
		String endTime = request.getParameter("endTime");
		String conStr = "";

		if(!"".equals(startTime)){
			conStr += " and yjtx01020 >='"+startTime+"' ";
		}
		if(!"".equals(endTime)){
			conStr += " and yjtx01020 <='"+endTime+"'";
		}

		String countHqlForWJLD = "select count(*) from YJCZ_YJTX01 where YJTX01050 = '2'"+conStr;
		String countHqlForDX = "select count(*) from YJCZ_YJTX01 where YJTX01040 = '3'"+conStr;
		String countHqlForCZ = "select count(*) from YJCZ_YJTX01 where YJTX01040 = '4'"+conStr;
		int wjdhCount = DbTools.getDataSQLCount(countHqlForWJLD);
		int dxCount = DbTools.getDataSQLCount(countHqlForDX);
		int czCount = DbTools.getDataSQLCount(countHqlForCZ);
		PageClass page = new PageClass();
		page.setPageShow(pageSize);  //设置每页显示的行数
		page.setPageCount(1);  //设置总页数
		page.setCurrentPage(Integer.parseInt(pageNo));  //设置当前页
		Ffbx ff = new Ffbx(wjdhCount, dxCount, czCount);
		List list = new ArrayList();
		list.add(ff);
		rows = list;
		total = 1;
		return SUCCESS;
	}
}
